from __future__ import annotations

from dataclasses import dataclass


@dataclass
class ConnectorCheck:
    required_strength_kN: float
    ok: bool
    note: str


def check_connector_strength(running_rope_tension_kN: float, safety_factor: float = 2.5, rated_strength_kN: float | None = None) -> ConnectorCheck:
    """旋转连接器/牵引板强度校核：按最大跑绳张力×安全系数确定需求。"""

    req = running_rope_tension_kN * safety_factor
    if rated_strength_kN is None:
        return ConnectorCheck(required_strength_kN=req, ok=False, note="请对照型录选择≥需求的型号")
    return ConnectorCheck(required_strength_kN=req, ok=rated_strength_kN >= req, note="按需求比对额定强度")


